<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<head>
    <link rel="stylesheet" type="text/css" href="/css/style_member.css" />
    <title>会员注册-笔飞美术作品</title>
    <%@include file="../common/js.jsp"%>
    <%@include file="../common/jspcommon.jsp"%>
	<%@include file="../common/css.jsp"%>
	
	<script type="text/javascript" src="js/jquery.validate.js"></script>
</head>
<body>
<div id="box">
     <%@include file="../common/header.jsp"%>
    <div id="main_div">
        <div class="site_map"><a href="/member.htm">首页</a> 》个人资料</div>
        <div id="member_div_2">
     
            <table cellpadding="0" cellspacing="0" class="member_table">
                <tr>
                    <td class="td_1" valign="top">
                        <div class="left_nav">
                        	<ul>
	                            <li><a href="/member.htm">控制面板</a></li>
	                            <li	class="cur"><a href="/memberInfo.htm">个人资料</a></li>
	                            <li	><a href="/mOrders.htm">我的订单</a></li>
	                            <li><a href="/mMade.htm">我的定制</a></li>
	                            <li ><a href="/mActivity.htm">我的活动</a></li>
	                            <li><a href="/mHas.htm">关注收藏欣赏</a></li>
	                            <li><a href="mComment.htm">评论管理</a></li>
	                            <li><a href="mPay.htm">支付保证金</a></li>
	                        </ul>
                        </div>
                    </td>
                    <td class="td_2" valign="top">
                        <table cellpadding="3" cellspacing="1" class="member_table2">
                            <tbody>
                                <tr class="td1">
                                    <td style="width:25%; height:50px;">
                                        <b><a href="/memberInfo.htm" class="current">账户信息</a></b>
                                    </td>
                                    <td style="width:25%;">
                                        <b><a href="/mBank.htm">银行帐号</a></b>
                                    </td>
                                    <td style="width:25%;">
                                        <b><a href="/mHobby.htm">我的喜好</a></b>
                                    </td>
                                    <td>
                                        <b><a href="/mAddress.htm">收货地址</a></b>
                                    </td>
                                </tr>
                                <tr class="td2">
                                    <td colspan="4">
                                        <table cellpadding="10" cellspacing="0" class="member_table3">
                                        <tr>
                                            <td colspan="2" class="td11">请在这里填写准确的个人资料</td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                            <div id="image">
	                                           	 	<img src="${member.avatar}" alt="" class="user_img"/>　
                                            </div>
                                            <form id="upload_img_form" enctype="multipart/form-data" method="post" action="/uploadImg.htm">
										                <input type="file" onchange="uploadImg(this);return false;"   name="imagef" id="imagef" style="width: 250px;height: 50px"/>
										                <br />只支持JPG、GIF、PNG格式
                              			   			</form>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="td22">E-mail：</td>
                                            <td align="left"> ${member.email }</td>
                                        </tr>
                                        <tr>
                                            <td>真实姓名：</td>
                                            <td align="left">
	                                            <input type="text" name="username" id="username_reg" value="${member.username}" style="width:220px; margin-right:10px;"/>
	                                            <select name="show_data" tabindex="10" id="show_data">
		                                            <option value="1"  <c:if test="${member.isPublic}">selected="selected"</c:if>>公开</option>
		                                            <option value="0" <c:if test="${!member.isPublic}">selected="selected"</c:if>>匿名</option>
	                                            </select>
	                                         </td>
                                        </tr>
                                        <tr>
                                            <td>联系电话：</td>
                                            <td align="left">
	                                            <input type="text" name="mobile" id="mobile_reg" style="width:320px;" value="${member.telphone }"/>
	                                         </td>
                                        </tr>
                                        <tr>
                                            <td>手机：</td>
                                            <td align="left">
	                                            <input type="text" name="mobile" id="Text1" value="${member.mobilephone }"style="width:320px;" />
	                                         </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="right"><a href="#"  onclick="saveInfo();"><img src="../images/btn_qrxg.jpg" alt="" /></a></td>
                                        </tr>
                                        
                                        <tr>
                                            <td colspan="2" class="td33"><span class="style5">修改密码</span><span class="font3">如果没有修改密码，请留空修改密码</span></td>
                                        </tr>
                                        <tr>
                                            <td class="td22">原密码：</td>
                                            <td align="left">
	                                            <input type="password" id="oldPassWord" name="oldPassWord" style="width:320px;"/>
	                                         </td>
                                        </tr>
                                        <tr>
                                            <td>新密码：</td>
                                            <td align="left">
                                            	<input type="password" id="newPassWord" name="newPassWord" style="width:320px;"/>
	                                         </td>
                                        </tr>
                                        <tr>
                                            <td>确认密码：</td>
                                            <td align="left">
												<input type="password" id="checkPassWord" name="checkPassWord" style="width:320px;"/>	                                           
	                                         </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="right">
                                            <input type="image" value="  " style="background-image:url(../images/btn_qrxg.jpg); width: 100px;height: 40px;margin:0; border:none; cursor:pointer; padding:0;" id="mpw_btn"  />
                                            </td>
                                        </tr>
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </table>
           
        </div>
       <%@include file="../common/footer.jsp" %>
    </div>
</div>

<script type="text/javascript">
	$("#passWordForm").validate(
		{
			rules : {
				oldPassWord : {
					required : true,
					remote : 'checkPassword.htm',
					maxlength : 20
				},
				newPassWord : {
					required : true,
					minlength : 6,
					maxlength : 20
				},
				checkPassWord:{
					required : true,
					equalTo:'#newPassWord'
				}
			},
			messages : {
				
				oldPassWord : {
					required : "请填写当前密码",
					remote : "密码不正确",
					maxlength : "请输入正确的密码"
				},
				newPassWord : {
					required : "请填写密码",
					minlength : "密码长度为6～20位",
					maxlength : "密码长度为6～20位"
				},
				checkPassWord:{
					required : "请填写确认密码",
					equalTo: "两次密码输入不符"
				}
			},
			submitHandler : function() {
				$.post("ModifyPw.htm", {
					newPassWord : $("#newPassWord").val()
					}, function(data) {
						if (data == 'success') {
							alert("修改成功");
						} else{
							alert("修改失败");
						}
					});
			}
		});
	function saveInfo(){
		var username=$("#username_reg").val();
		var isPublic=$("#show_data").val();
		var phone =$("#Text1").val();
		var telphone =$("#mobile_reg").val();
		
		if(username ==null || isPublic ==null || phone ==null || telphone ==null ){
			alert("还有未填写的资料哦。")
			return false;
		}
		$.post("/saveInfo.htm",  {
			username:username,
			isPublic:isPublic,
			mobilephone:phone,
			telphone:telphone
		}, function(data){
			if(data=="success"){
				window.location.href="/memberInfo.htm"
			}
			if(data=="error"){
				alert("保存失败了。");
			}
		});
	}
	function uploadImg(self) {
		var filepath = $(self).val();
		var extStart = filepath.lastIndexOf(".");
		var ext = filepath.substring(extStart, filepath.length).toUpperCase();
		if (ext != ".PNG" && ext != ".JPG" && ext != ".JPEG" && ext != ".GIF") {
			alert("图片限于png,jpeg,jpg,gif格式");
			return;
		}
		$("#upload_img_form").ajaxSubmit({
			dataType : 'json',
			cache : false,
			success : function(data) {
				$("#image").html("<img  id='avatar' width='80px'  src='"+data.imageServer+data.imageUrl+"'>");
				var avatar =data.imageServer+data.imageUrl;
				$.post("/saveInfo.htm",  {
					avatar : avatar
				}, function(data){
					if(data=="success"){
						window.location.href="/memberInfo.htm"
					}
					if(data=="error"){
						alert("保存失败了。");
					}
				});
			},
			error : function(err) {
				alert(err);
			}
		});
		return false;
	}
	</script>
</body>
</html>
